import { defineStore } from "pinia";
import { ref } from "vue";

export const useUserStore = defineStore('users', () => {
    const token = ref()

    // 设置token
    const setToken = (newToken: string) => {
        token.value = newToken
    }
    // 清空token
    const clearToken = () => {
        token.value = ''
    }
    const username = ref()
    // 设置username
    const setUsername = (newUsername: string) => {
        username.value = newUsername
    }
    const clearUsername = () => {
        username.value = ''
    }
    return { token, username, setToken, clearToken, setUsername, clearUsername }
}, { persist: true })